/**
 * 
 */
package com.bree.erp.report.birt;

import java.io.InputStream;

import org.apache.log4j.Logger;
import org.eclipse.birt.report.engine.api.IRunAndRenderTask;

import com.bree.erp.report.birt.param.PurchaseRequestFormParam;
import com.bree.erp.report.entity.po.PurchaseRequestDataSet;

/**
 * @author bringinoo
 *
 */
public class PurchaseRequestForm extends AbstractReport {

	private static Logger LOG = Logger.getLogger(PurchaseRequestForm.class);
	
	private PurchaseRequestDataSet purchaseRequestDataSet;
	private PurchaseRequestFormParam param;
	
	public PurchaseRequestForm(PurchaseRequestFormParam param) {
		this.param = param;
	}

	/* (non-Javadoc)
	 * @see com.bree.erp.report.birt.AbstractReport#getReportDesign()
	 */
	@Override
	protected InputStream getReportDesign() {
		final String resourceName = this.getReportName() + ".rptdesign";
		InputStream is = PurchaseOrderForm.class.getResourceAsStream(resourceName);
		
		LOG.debug(resourceName + " @ " + is);
		
		return is;
	}

	/* (non-Javadoc)
	 * @see com.bree.erp.report.birt.AbstractReport#getReportName()
	 */
	@Override
	protected String getReportName() {
		return this.getClass().getSimpleName();
	}

	/* (non-Javadoc)
	 * @see com.bree.erp.report.birt.AbstractReport#getDataSet()
	 */
	@Override
	protected Object getDataSet() {
		// TODO Auto-generated method stub
		return purchaseRequestDataSet;
	}

	/* (non-Javadoc)
	 * @see com.bree.erp.report.birt.AbstractReport#setParameterValues(org.eclipse.birt.report.engine.api.IRunAndRenderTask)
	 */
	@Override
	protected void setParameterValues(IRunAndRenderTask task) {
		
		task.setParameterValue("projectName", param.getProjectName());
		task.setParameterValue("requisitionDate", param.getRequisitionDate());
		task.setParameterValue("prNumber", param.getPrNumber());
		task.setParameterValue("description", param.getDescription());
		task.setParameterValue("jobNumber", param.getJobNumber());
		task.setParameterValue("remarks", param.getRemarks());
		task.setParameterValue("requestedBy", param.getRequestedBy());
		task.setParameterValue("approvedBy", param.getApprovedBy());
	}

	/**
	 * @return the purchaseRequestDataSet
	 */
	public PurchaseRequestDataSet getPurchaseRequestDataSet() {
		return purchaseRequestDataSet;
	}

	/**
	 * @param purchaseRequestDataSet the purchaseRequestDataSet to set
	 */
	public void setPurchaseRequestDataSet(
			PurchaseRequestDataSet purchaseRequestDataSet) {
		this.purchaseRequestDataSet = purchaseRequestDataSet;
	}

}
